package scnu.cs2020.lzd;

public class rational_number
{
    private int a;
    private int b;



   public  rational_number()
    {
     a=0;b=a;
    }
   public rational_number(int a,int b)
    {
        this.a=a; this.b=b;
    }

    private static int getgcd(int x,  int y)
    {
        return (x%y==0) ? y:getgcd(y,x%y);
    }

    private void simplify()
    {
        int temp=getgcd(a,b);
        a/=temp; b/=temp;
    }

    public  double getValue()
    {
        simplify();
        return  ((double)a)/b;
    }

    public String toString()
    {
        simplify();
        return ""+a+"/"+b;
    }

}
